﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Calculate_PI
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 1;
            double sum = 0;
            double temp = 0.0;
            do
            {
                temp = 1 / (double)(2 * n + 1);
                if (n %2==0)
                {
                    sum = sum - temp;
                }
                else
                {
                    sum = sum + temp;
                }
                n++;
            } 
            while (temp >0.000001);
            double PI = 4 * (1 - sum);
            Console.WriteLine($"输出{PI}");
            Console.ReadKey();
        }
    }
}
